// 此文件是用来登录发送axios请求的
// 1.引入axios包
import axios from "axios";

// 2.设置基准路径
axios.defaults.baseURL = "http://157.122.54.189:9073/api/";

// 获取首页轮播图数据
export const getSwipeData = () => {
  return axios.get("getlunbo").then((res) => {
    return res.data;
  });
};

// 获取图文资讯
export const getPageTextData = () => {
  return axios.get("getnewslist").then((res) => {
    return res.data;
  });
};
// 新闻详情页面
export const getPageNewData = (id) => {
  return axios.get(`getnew/${id}`).then((res) => {
    return res.data;
  });
};
// 获取图文资讯
export const getnewsListData = () => {
  return axios.get("getimgcategory").then((res) => {
    return res.data;
  });
};
// 获取图片列表数据
export const getimagesData = (id) => {
  return axios.get(`getimages/${id}`).then((res) => {
    return res.data;
  });
};
// 获取图片详情
export const getimageInfoData = (id) => {
  return axios.get(`getimageInfo/${id}`).then((res) => {
    return res.data;
  });
};
// 图片分享详情中的缩略图数组
export const getthumimagesData = (id) => {
  return axios.get(`getthumimages/${id}`).then((res) => {
    return res.data;
  });
};
// 获取商品列表数据
export const getgoodsData = (pageindex) => {
  return axios.get("getgoods?pageindex=" + pageindex).then((res) => {
    return res.data;
  });
};
// 获取商品列表数据
export const getdescData = (id) => {
  return axios.get(`goods/getinfo/${id}`).then((res) => {
    return res.data;
  });
};
// 获取商品图文介绍
export const getdescTuData = (id) => {
  return axios.get(`goods/getdesc/${id}`).then((res) => {
    return res.data;
  });
};
// 获取评论信息
export const getcommentsData = (id, pageindex) => {
  return axios.get(`getcomments/${id}?pageindex=` + pageindex).then((res) => {
    return res.data;
  });
};
// 提交评论信息
export const postcommentData = (id, data) => {
  return axios.post(`postcomment/${id}`, data).then((res) => {
    return res.data;
  });
};
// 获取购物车页面数据
export const getshopcarlistData = (ids) => {
  return axios.get(`goods/getshopcarlist/${ids}`).then((res) => {
    return res.data;
  });
};
